package com.mysecurity.controller;

import com.mysecurity.utils.Result;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Jane
 * @date 2024-07-05 17:45
 */
@Controller
public class RightController {

    @RequestMapping("/L0301")
    @ResponseBody
    public Result l0301(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        System.out.println(authentication.getPrincipal());
        System.out.println(authentication.getAuthorities());
        System.out.println(authentication.getCredentials());
        System.out.println(authentication.getDetails());

        Map<String,Object> maps = new HashMap<>();
        maps.put("auth_code", authentication.getAuthorities().toArray());
        return Result.ok(maps).message("服务创建");
        //return "服务创建";
    }

    @RequestMapping("/L0302")
    @ResponseBody
    public String l0302(){
        return "服务分配";
    }


    @RequestMapping("/L0303")
    @ResponseBody
    public String l0303(){
        return "服务处理";
    }
}
